<?php

require_once __DIR__ . '/../Locale.php'; // only needed for PHPUnit

class Rsj_Locale_RawPhp extends Rsj_Locale
{
    public function getTypeOfLocaleProcessor()
    {
        return "Raw PHP Locale";
    }

    /**
     *
     *
     * @assert ('JP') === 'JP'
     * @assert ('ja_JP') === 'Japan'
     * @assert ('en_US') === 'USA'
     * @assert ('hoge') === 'hoge'
     */
    public function getDisplayRegion( $regionCode )
    {
				$codeArray = explode('_', $regionCode);
var_dump($codeArray);
				if (count($codeArray) === 1) {
					$key = strtoupper($codeArray[0]);
				} if (count($codeArray) > 1) {
					// I know it is not a great way, you need php_intl if want perfect...
					$key = strtoupper($codeArray[1]);
				} else {
					return $regionCode;
				}
				if (array_key_exists($key, self::$countries)) {
	        return self::$countries[$key];
				} else {
					return $regionCode;
				}
    }

    /**
     *
     *
     * @assert ('us') === 'us'
     * @assert ('ja_JP') === 'ja_JP'
     * @return formatted region name
     */
    public function getDisplayLanguage( $languageCode )
    {
        return $languageCode;
    }

    /**
     *
     *
     * @assert ('12345', 'USD') === '12,345 (USD)'
     * @assert ('6789', 'JPY') === '6,789 (JPY)'
     * @return formatted price with currency
     */
    public function formatCurrency( $value, $currency, $type = 'ignored' )
    {
        $currentLocale = setlocale( LC_MONETARY, 0 );

        return number_format( $value ) . " ($currency)";
    }

    /**
     *
     *
     * @assert ('12345') === '12345'
     * @assert ('6789') === '6789'
     */
    public function format( $value, $type = 'ignored' )
    {
        return $value;
    }

    public static $countries = array(
        "US" => "USA",
        "JP" => "Japan",
        "AR" => "Argentina",
        "AU" => "Australia",
        "AT" => "Austria",
        "BE" => "Belgium",
        "BR" => "Brazil",
        "CA" => "Canada",
        "CL" => "Chile",
        "CN" => "China",
        "CO" => "Colombia",
        "CR" => "Costa Rica",
        "HR" => "Croatia",
        "CZ" => "Czech Republic",
        "DK" => "Denmark",
        "DO" => "Dominican Rep.",
        "EC" => "Ecuador",
        "EG" => "Egypt",
        "SV" => "El Salvador",
        "EE" => "Estonia",
        "FI" => "Finland",
        "FR" => "France",
        "DE" => "Germany",
        "GR" => "Greece",
        "GT" => "Guatemala",
        "HN" => "Honduras",
        "HK" => "Hong Kong",
        "HU" => "Hungary",
        "IN" => "India",
        "ID" => "Indonesia",
        "IE" => "Ireland",
        "IL" => "Israel",
        "IT" => "Italy",
        "JM" => "Jamaica",
        "KZ" => "Kazakstan",
        "KR" => "Korea, Republic Of",
        "KW" => "Kuwait",
        "LV" => "Latvia",
        "LB" => "Lebanon",
        "LT" => "Lithuania",
        "LU" => "Luxembourg",
        "MO" => "Macau",
        "MY" => "Malaysia",
        "MT" => "Malta",
        "MX" => "Mexico",
        "MD" => "Moldova, Republic Of",
        "NL" => "Netherlands",
        "NZ" => "New Zealand",
        "NI" => "Nicaragua",
        "NO" => "Norway",
        "PK" => "Pakistan",
        "PA" => "Panama",
        "PY" => "Paraguay",
        "PE" => "Peru",
        "PH" => "Philippines",
        "PL" => "Poland",
        "PT" => "Portugal",
        "QA" => "Qatar",
        "RO" => "Romania",
        "RU" => "Russia",
        "SA" => "Saudi Arabia",
        "SG" => "Singapore",
        "SK" => "Slovakia",
        "SI" => "Slovenia",
        "ZA" => "South Africa",
        "ES" => "Spain",
        "LK" => "Sri Lanka",
        "SE" => "Sweden",
        "CH" => "Switzerland",
        "TW" => "Taiwan",
        "TH" => "Thailand",
        "TR" => "Turkey",
        "GB" => "UK",
        "AE" => "United Arab Emirates",
        "UY" => "Uruguay",
        "VE" => "Venezuela",
        "VN" => "Vietnam",
    );
}
